package com.kevin.utils;

import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.kevin.utils.common.KnCommonUtils;

public class StaticTool {
	public static Object changeType(Object value, Class<?> clazz) throws Exception {
		return KnCommonUtils.changeType(value, clazz);
	}

	static Map<String, String> hashKeyCache = new ConcurrentHashMap<>(32);

	public static String getHashKey(String key) {
		try {
			if (hashKeyCache.containsKey(key)) {
				return hashKeyCache.get(key);
			} else {
				if (hashKeyCache.size() > 512) {
					hashKeyCache.clear();
					hashKeyCache = new HashMap<>(64);
				}
				String value = "K" + Math.abs(key.hashCode()) + key.length();
				hashKeyCache.put(key, value);
				return value;
			}
		} catch (Exception e) {
			return key;
		}
	}
}
